package com.fjec.base.controller;

import com.fjec.base.service.ICommonService;
import com.fjec.common.enums.EnumSysCode;
import com.fjec.common.protocol.JsonResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/")
public class CommonController {

    @Resource
    private ICommonService service;

    /**
     * 发送注册短信验证码
     *
     * @param phoneNum
     * @return
     */
    @GetMapping("/n/comm/regVerifyCode/get")
    public JsonResult getRegVerifyCode(String phoneNum) {
        String code = service.getVerifyCode(phoneNum);
        service.sendRegVerifyCode(phoneNum, code);
        return JsonResult.success()
                .code(EnumSysCode.MSG_6001.getCode())
                .message(EnumSysCode.MSG_6001.getMsg())
                .build();
    }

    /**
     * 发送修改用户信息短信验证码
     *
     * @param phoneNum
     * @return
     */
    @GetMapping("/y/comm/chgUserInfo/get")
    public JsonResult sendChgUserInfo(String phoneNum) {
        String code = service.getVerifyCode(phoneNum);
        service.sendChgUserInfo(phoneNum, code);
        return JsonResult.success()
                .code(EnumSysCode.MSG_6001.getCode())
                .message(EnumSysCode.MSG_6001.getMsg())
                .build();
    }
}
